#!/usr/bin/python2.4
#
# Copyright 2009-2010 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ========================================================================


Import('env')


#
# Build executecustomaction.dll
#

lib_target_name = 'executecustomaction_lib'

lib_env = env.Clone()

lib_inputs = [
    'execute_repair_file.cc',
    ]

lib_output = lib_env.ComponentLibrary(
    lib_name=lib_target_name,
    source=lib_inputs,
)

dll_target_name = 'executecustomaction'

dll_env = env.Clone(
    # Build a dll, not a lib.
    COMPONENT_STATIC = False,
)

dll_env.Append(
    LIBS = [
        dll_env['atls_libs'][dll_env.Bit('debug')],
        dll_env['crt_libs'][dll_env.Bit('debug')],
        '$LIB_DIR/base.lib',
        '$LIB_DIR/common.lib',
        '$LIB_DIR/crx_file.lib',
        '$LIB_DIR/google_update_recovery.lib',
        '$LIB_DIR/libprotobuf.lib',
        '$LIB_DIR/repair_goopdate.lib',
        '$LIB_DIR/security.lib',
        'crypt32.lib',
        'msi.lib',
        '$LIB_DIR/net.lib',
        'wintrust.lib',

        # These are required by base.lib
        'netapi32.lib',
        'psapi.lib',
        'shlwapi.lib',
        'userenv.lib',
        'version.lib',
        'wtsapi32.lib',
        lib_target_name + '.lib',
        ],

    CPPDEFINES = [
        '_USRDLL',
        ],
)

dll_inputs = [
    'executecustomaction.cc',
    'executecustomaction.def',
    ]

dll_env.ComponentLibrary(
    lib_name=dll_target_name,
    source=dll_inputs,
)


#
# Build testelevateusingmsp.exe
#
test_env = env.Clone()

test_env['LIBS'] += [
    test_env['atls_libs'][test_env.Bit('debug')],
    test_env['crt_libs'][test_env.Bit('debug')],
    '$LIB_DIR/base.lib',
    '$LIB_DIR/repair_goopdate.lib',
    'crypt32.lib',
    'msi.lib',
    'wintrust.lib',
    # These are required by base.lib
    'netapi32.lib',
    'psapi.lib',
    'shlwapi.lib',
    'userenv.lib',
    'version.lib',
    'wtsapi32.lib',
    ]

# This is a console application.
test_env.FilterOut(LINKFLAGS = ['/SUBSYSTEM:WINDOWS,5.01'])
test_env['LINKFLAGS'] += ['/SUBSYSTEM:CONSOLE,5.01']

target_name = 'testelevateusingmsp'

test_inputs = [
    'testelevateusingmsp.cc',
    ]

# This test requires arguments, so do not create a run alias.
test_env.ComponentTestProgram(
    prog_name=target_name,
    source=test_inputs,
    COMPONENT_TEST_RUNNABLE=False
)
